import java.util.*;

public class WithYou {
    public static void main(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//        int size = scanner.nextInt();
//        int[] arr = new int[size];
//        for (int i = 0; i < size; i++) {
//            arr[i] = scanner.nextInt();
//        }
//
        int[] A = new int[]{2, 10, 9, 8, 7, 6};
        int[] B = new int[]{9, 5, 4, 2, 1};
        int[] C = merge(A, 0, A.length - 1);
        for (int i = 0; i < C.length; i++) {
            System.out.print(C[i] + " ");
        }

    }

    //    其实很简单，从大到小排序
    public static void fun(int[] arr) {
        
    }

    public static int[] sortM(int[] arrA, int[] arrB) {
        int[] arrC = new int[arrA.length + arrB.length];
        int indexA = 0, indexB = 0, indexC = 0;
        while (true) {
            if (indexA >= arrA.length || indexB >= arrB.length)
                break;
            if (arrA[indexA] >= arrB[indexB]) {
                arrC[indexC++] = arrA[indexA++];
            } else if (arrA[indexA] < arrB[indexB]) {
                arrC[indexC++] = arrB[indexB++];
            }
        }
        while (indexA < arrA.length) {
            arrC[indexC++] = arrA[indexA++];
        }
        while (indexB < arrB.length) {
            arrC[indexC++] = arrB[indexB++];
        }
        return arrC;
    }

    public static int[] merge(int[] arr, int start, int end) {
        if (start >= end)
            return new int[]{arr[start]};
        int mid = (start + end) / 2;
        int[] A = merge(arr, start, mid );
        int[] B = merge(arr, mid+1, end);
        return sortM(A, B);
    }


}
